<!doctype HTML>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<div contenteditable="true">
<sub><i>1. Make text subscript and italic</i></sub>
<sup><i>2. Make text superscript and italic</i></sup>
</div>
<div id="log"></div>
<script>
function test_sub() {
    document.getSelection().removeAllRanges();
    var range = document.createRange();
    range.selectNode(document.querySelector('i'));
    document.getSelection().addRange(range);

    assert_equals(document.queryCommandState('subscript'), true);
}

function test_sup() {
    document.getSelection().removeAllRanges();
    var range = document.createRange();
    range.selectNode(document.querySelectorAll('i')[1]);
    document.getSelection().addRange(range);

    assert_equals(document.queryCommandState('superscript'), true);
}

function test_all(platform) {
    if (platform)
        internals.settings.setEditingBehavior(platform);
    test(test_sub, `${platform}: run queryCommandState('subscript')`);
    test(test_sup, `${platform}: run queryCommandState('superscript')`);
}

(window.internals ? ['mac', 'win',''] : ['']).forEach(test_all);
</script>
